import axios from "@/plugins/axios";

const data = {
    token: "1f8e3466-2f26-4bc7-9325-a0354fb75c52",
    projectId: "7b30b7658f60432ea85175d8106afccf"
};

const loadSections = function () {
    return axios({
        url: `${process.env.VUE_APP_URL_PAS}/section/list`,
        method: "post",
        headers: {
            token: data.token
        },
        data: {
            pageNum: "1",
            pageSize: "0",
            condition: {
                projectId: data.projectId
            }
        }
    });
};

const wfsRequest = function (xmlData, responseType = "json") {
    return axios({
        url: `${process.env.VUE_APP_URL_GEOSERVER}/ewp/wfs`,
        method: "post",
        headers: {
            "Content-Type": "application/xml;charset=UTF-8"
        },
        responseType: responseType,
        data: new XMLSerializer().serializeToString(xmlData)
    });
};

export default {
    data,
    loadSections,
    wfsRequest
};